package 二叉搜索数;

/**
 * https://leetcode.cn/problems/search-in-a-binary-search-tree/
 *
 * 题解：https://mp.weixin.qq.com/s?__biz=MzAxODQxMDM0Mw==&mid=2247493449&idx=1&sn=e2e8132b22fe8258ab47e32e0d22d49a&chksm=9bd41941aca3905781e4d38759eeb6fe7ba1f28adc86dfb0a0b4e87e3856ec79b224ed53f106&scene=178&cur_album_id=2165105273311494144#rd
 */
public class _700_二叉搜索树中的搜索 {

    public TreeNode searchBST(TreeNode root, int val) {
        if (root == null) return null;
        if (root.val == val) return root;

        if (root.val > val) {
            return searchBST(root.left, val);
        } else {
            return searchBST(root.right, val);
        }
    }
}